


adaptation();
window.onresize = function(){
    adaptation();
}

function adaptation(){
    var html = document.querySelector("html");
    var width = html.getBoundingClientRect().width;
    if(width >420){
        html.style.width=420 + "px";
        html.style.fontSize = 420/16 + "px";
    }else {
        html.style.fontSize = width/16 + "px";
    }
}
//获取url中的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return decodeURI(r[2]); return null; //返回参数值
}
/*打开弹出层*/
function layer_layer(title, url,cancelUrl) {
    layer.open({
        area: ['542px', '503px'],
        title: title,
        type: 2,
        fix: true,
        resize: false,
        end: function () {
            location.reload();
        },
        content: [url, 'no'],
        cancel: function (index, layero) {
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
            //{:\\think\\Url::build("index/User/successregister",["memberId"=>'+memberId+'])}
            window.open (cancelUrl);
            // window.open('setpwd.html'+memberId);
        }
    });
}

/*关闭弹出层跳转到新页面*/
function close_layer(url) {
    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index); //再执行关闭
    window.open(url);

}
/*关闭弹出层不跳转*/
function close_layer2() {
    parent.location.reload();
    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index); //再执行关闭

}
//查看原图
function layer_open(title, url) {
    var index=  layer.open({
        type:2,
        fix: false, // 不固定
        maxmin: true,
        shade: 0.4,
        title: title,
        content: url,
    });
    layer.full(index);
}
function layer_layer2(title, url, w, h,margin_l,margin_t) {
    var index = layer.open({
        area: [w, h],
        title: title,
        type: 2,
        fix: true,
        resize: false,
        offset:['29%','11%'],
        content: [url, 'no'],
    });
    $("#layui-layer"+index).css({
        'margin-left':margin_l,
        'margin-top':margin_t
    });
}
function layer_layer3() {
    layer.open({
        title: "",
        type: 1,
        closeBtn: 0,
        resize: false,
        time: 6000,
        area: ['464px', '182px'], //宽高
        content: '<div style="position: relative;">' +
        '<div style="width: 400px;margin: 0 auto;margin-top: 50px;font-size: 16px;"> 请确保您提供的提现账户为您个人或对公合法有效账户。 如不是，出现任何资金安全问题，企业宝概不负责!</div>' +
        '<div id = "id1" style="width: 70px;margin: 0 auto;margin-top:30px;text-align: center;background: #22A0DB;border-radius: 3px;height: 30px;line-height: 30px;font-size: 16px;color: white;">5S</div>' +
        '</div>',
        success: function (layer) {
            var count = 4;
            var countdown = setInterval(CountDown, 1000);

            function CountDown() {
                $("#id1").html(count + "S");
                if (count == 0) {
                    clearInterval(countdown);
                }
                count--;
            }
        },
        end: function () {
            $("#fengxian").attr('checked', 'true');
            $('.dedisabled').removeClass('dedisabled');
            $('#submit').attr("disabled",false).removeClass('disabled')
            // $('#submit').on('click', function () {
            //     return searchSub23();
            //     //$('#register').submit();
            //     layer_layer4();
            // });
        }
    });
}
function attr_support(attrName, attrValue) {
    try {
        var element = document.createElement('div');
        if (attrName in element.style) {
            element.style[attrName] = attrValue;
            return element.style[attrName] === attrValue;
        } else {
            return false;
        }
    } catch (e) {
        return false;
    }
}
function layer_layer4() {
    layer.open({
        title: "",
        type: 1,
        closeBtn: 0,
        resize: false,
        time: 3000,
        area: ['464px', '182px'], //宽高
        content: '<div style="width: 400px;margin: 0 auto;margin-top: 50px;font-size: 16px;"> 亲，您的信息已成功提交了。 管理员正在审核，请耐心等待。 本站目前支持线下打款，审核通过后将为您打款。</div>',
        end: function () {
            location.reload();

        }
    });
}
/*打开新页面*/
function btn(url) {
    window.open(url);
}
function formresult(res) {
    if (res == 'yes') {
        //$('.yes').css('display','block');
        $('.modeltype').css('marginTop', '15px');
        $(".yes").show();
    }
    ;
    if (res == 'no') {
        //$('.no').css('display','block');
        $('.modeltype').css('marginTop', '15px');
        $(".no").show();
    }
}
/*上传图片并显示*/
function preview(file, id) {
    var prevDiv = document.getElementById(id);
    if (file.files && file.files[0]) {
        var reader = new FileReader();
        reader.onload = function (evt) {
            prevDiv.innerHTML = '<img class="img" src="' + evt.target.result + '" />';
        }
        console.log(file.files[0]['name']);
        reader.readAsDataURL(file.files[0]);

    }
    else {
        prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
    }
}

/*上传图片并显示*/
function preview4(file, id) {
    var prevDiv = document.getElementById(id);
    if (file.files && file.files[0]) {
        var filename = file.files[0]['name'];
        prevDiv.innerHTML = "您已选择" + filename;
    }
    else {
        prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
    }
}


/*上传身份证并显示*/
function preview2(file, id) {
    var prevDiv = document.getElementById(id);
    if (file.files && file.files[0]) {
        var reader = new FileReader();
        reader.onload = function (evt) {
            prevDiv.innerHTML = '<img class="img2" src="' + evt.target.result + '" />';
        }
        reader.readAsDataURL(file.files[0]);
    }
    else {
        prevDiv.innerHTML = '<div class="img2" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
    }

}